﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using OgilvyOne.SqlServerDAL;
using OgilvyOne.Model;

namespace OgilvyOne.BLL
{
    public class BLLArticleInfo
    {
        private static string _sql;
        private static IDAL.IDALArticleInfo iuser = DALFactory.CreateInstance.CreateArticleInfo();

        public static int insert(Model.Nestle_ArticleInfo info)
        {
            _sql = Utility.SqlTool.buildInsertSql(info);
            return iuser.getScalar(_sql);
        }

        public static int insertFaq(nestle_doctor_FAQ info)
        {
            _sql = Utility.SqlTool.buildInsertSql(info);
            return iuser.insert(_sql);
        }


        public static DataTable GetArticle()
        {
            string sql = string.Format("select * from Nestle_ArticleInfo");
            return iuser.query(sql);
        }

        public static int count()
        {
            string sql = string.Format("select count(id) from Nestle_ArticleInfo");
            return iuser.select(sql);
        }

        public static int updateTopPic(string topPic, int articleId)
        {
            string sql = string.Format("update CMS_ARTICLE set toppic='{0}' where ARTICLEID={1}", topPic, articleId);
            return iuser.insert(sql, new SqlParameter[0]);
        }

        public static int updateHotPic(string hotPic, int articleId)
        {
            string sql = string.Format("update CMS_ARTICLE set hotpic='{0}' where ARTICLEID={1}", hotPic, articleId);
            return iuser.insert(sql, new SqlParameter[0]);
        }
        public static int updatePic(string pic, int articleId)
        {
            string sql = string.Format("update CMS_ARTICLE set pic='{0}' where ARTICLEID={1}", pic, articleId);
            return iuser.insert(sql, new SqlParameter[0]);
        }

        public static int check(int param)
        {
            string sql = string.Format("select * from CMS_ARTICLE_IMGS where IMG_TYPE={0}", param);
            return iuser.select(sql);
        }

        public static DataTable selImgType(string Imgid)
        {
            string sql = string.Format("select * from CMS_ARTICLE_IMGS where IMGS_ID={0}", Imgid);
            return iuser.query(sql);
        }

        public static DataTable selArticle(string aid)
        {
            string sql = string.Format("select * from CMS_ARTICLE where ARTICLEID={0}", aid);
            return iuser.query(sql);
        }

        public static DataTable selArticle()
        {
            string sql = string.Format("select * from CMS_ARTICLE");
            return iuser.query(sql);
        }



        public static DataTable selTop1()
        {
            string sql = string.Format("select top 1 from CMS_ARTICLE order by ARTICLEID desc");
            return iuser.query(sql);
        }



        public static DataTable selEnamee(string cid)
        {
            string sql = string.Format("; WITH colname AS (SELECT * FROM cms_column WHERE classid = {0} UNION ALL SELECT a.* FROM cms_column a JOIN colname f ON a.classid = f.parentid) SELECT * FROM colname WHERE parentid > 1 ORDER BY classid", cid);
            return iuser.query(sql);
        }

        public static DataTable selEname(string cid)
        {
            string sql = string.Format("SELECT * FROM cms_column WHERE classid = {0}", cid);
            return iuser.query(sql);
        }



        public static int updataArticle(string doKnow, string recommend, string banner, string modtime, string articleId)
        {
            string sql = string.Format("update CMS_ARTICLE set doKnow='{0}',recommend={1},isbanner={2},modtime='{3}' where ARTICLEID={4}", doKnow, recommend, banner,modtime, articleId);
            return iuser.insert(sql, new SqlParameter[0]);
        }

        public static int updataArticleSeo(string ispub, string pagename, string titles, string kwords, string artdesc, string articleId)
        {
            string sql = string.Format("update CMS_ARTICLE set isstaticpub='{0}',STATICPAGENAME='{1}',ARTICLETITLE='{2}',ARTICLEKEYWORD='{3}',ARTICLEDESC='{4}' where ARTICLEID={5}", ispub, pagename, titles, kwords, artdesc, articleId);
            return iuser.insert(sql, new SqlParameter[0]);
        }


        public static int updataEname(string pename, string cename, string articleId)
        {
            string sql = string.Format("update CMS_ARTICLE set parentename='{0}',childenamel='{1}'where ARTICLEID={2}", pename, cename, articleId);
            return iuser.insert(sql, new SqlParameter[0]);
        }

        public static int updstaticname(string staticname,string arttile, string artkewords,string artdesc,string articleId)
        {
            string sql = string.Format("update CMS_ARTICLE set STATICPAGENAME='{0}',ARTICLETITLE='{1}',ARTICLEKEYWORD='{2}',ARTICLEDESC='{3}' where ARTICLEID={4}", staticname, arttile, artkewords, artdesc, articleId);
            return iuser.insert(sql, new SqlParameter[0]);
        }



        public static int insArticle(string doKnow, string recommend)
        {
            string sql = string.Format("insert into CMS_ARTICLE (doKnow,recommend) VALUES('{0}','{1}') ;SELECT @@IDENTITY", doKnow, recommend);
            return iuser.insert(sql, new SqlParameter[0]);
        }

        public static DataTable selecta()
        {
            string sql = string.Format("select top 2 * from CMS_ARTICLE where SORTTOP=1 and COLUMNID=197 order by ADD_TIME");
            return iuser.query(sql);
        }

        public static DataTable selectzmb()
        {
            string sql = string.Format("select * from CMS_ARTICLE where COLUMNID=180 order by ADD_TIME");
            return iuser.query(sql);
        }

        public static DataTable selectb(string columid)
        {
            string sql = string.Format("select * from CMS_ARTICLE where COLUMNID={0}", columid);
            return iuser.query(sql);
        }
        public static DataTable getEname(string columid)
        {
            string sql = string.Format("select * from CMS_COLUMN where CLASSID={0}", columid);
            return iuser.query(sql);
        }

        public static DataTable getSeoInfo(string columid)
        {
            string sql = string.Format("select * from CMS_COLUMN where CLASSID={0}", columid);
            return iuser.query(sql);
        }



        public static DataTable selectc(string columnID)
        {
            string sql = string.Format("select top 6 * from CMS_ARTICLE where COLUMNID={0} order by ADD_TIME",columnID);
            return iuser.query(sql);
        }

        public static DataTable selectw(string columnID)
        {
            string sql = string.Format("select top 5 * from CMS_ARTICLE where COLUMNID={0} order by ADD_TIME", columnID);
            return iuser.query(sql);
        }


        public static DataTable selectc(string field,string vlaues)
        {
            string sql = string.Format("select top 1 * from CMS_ARTICLE where {0}={1} order by ADD_TIME", field,vlaues);
            return iuser.query(sql);
        }

        public static DataTable selectc(string topNum,string field, string vlaues)
        {
            string sql = string.Format("select top {0} * from CMS_ARTICLE where {1}={2} order by ADD_TIME", topNum, field, vlaues);
            return iuser.query(sql);
        }




        public static DataTable GetArticle(string max, string pageNum, string columnid, string columnid2)
        {
            string sql = string.Format("select top {0} * from CMS_ARTICLE where (  ARTICLEID not in(select top {1} ARTICLEID from CMS_ARTICLE where COLUMNID={2} order by ARTICLEID desc)) and COLUMNID={3} order by ARTICLEID desc", max, pageNum, columnid, columnid2);
            return iuser.query(sql);
        }

        public static int count(string columnid)
        {
            string sql = string.Format("select count(ARTICLEID) from CMS_ARTICLE where COLUMNID={0}", columnid);
            return iuser.getScalar(sql);
        }

        public static int chekArticle(string max, string pageNum, string columnid)
        {
            string sql = string.Format("select top {0} * from CMS_ARTICLE where (  ARTICLEID not in(select top {1} ARTICLEID from CMS_ARTICLE order by COLUMNID desc)) and COLUMNID={2} order by ARTICLEID desc", max, pageNum, columnid);
            return iuser.select(sql);
        }

        public static DataTable GetArticleContent(string columnid, string articleid)
        {
            string sql = string.Format("select * from CMS_ARTICLE where COLUMNID={0} and ARTICLEID={1}", columnid, articleid);
            return iuser.query(sql);
        }

        public static DataTable GetRecommend(string columnId)
        {
            string sql = string.Format("select * from CMS_ARTICLE where recommend=1 and COLUMNID={0}", columnId);
            return iuser.query(sql);
        }

        public static DataTable GetDoKnow()
        {
            string sql = string.Format("select * from CMS_ARTICLE where doKnow=1");
            return iuser.query(sql);
        }

        public static DataTable getColumnName(string classId)
        {
            string sql = string.Format("select * from CMS_COLUMN where CLASSID={0}", classId);
            return iuser.query(sql);
        }

        public static DataTable Getindextop(string columnId)
        {
            string sql = string.Format("select top 5 * from CMS_ARTICLE where INDEXTOP=1 and COLUMNID={0} order by ARTICLEID", columnId);
            return iuser.query(sql);
        }

        public static int insertdoctor(Model.nestle_doctor info)
        {
            _sql = Utility.SqlTool.buildInsertSql(info);
            return iuser.getScalar(_sql);
        }

        public static int insertkeyword(Model.nestle_kewords info)
        {
            _sql = Utility.SqlTool.buildInsertSql(info);
            return iuser.getScalar(_sql);
        }



        public static DataTable getDoctor()
        {
            string sql = string.Format("select * from nestle_doctor");
            return iuser.query(sql);
        }
        public static DataTable getDoctor(string id)
        {
            string sql = string.Format("select * from nestle_doctor where id={0}", id);
            return iuser.query(sql);
        }


        public static int countDoctor()
        {
            string sql = string.Format("select count(id) from nestle_doctor");
            return iuser.getScalar(sql);
        }

        public static int countkeywords()
        {
            string sql = string.Format("select count(id) from nestle_kewords");
            return iuser.getScalar(sql);
        }



        public static bool Del(string ids)
        {
            bool re = false;
            string delsql = string.Format("delete from nestle_doctor where id in({0})", ids);
            int i = SQLHelper.ExecuteSql(delsql, new SqlParameter[] { });
            if (i > 0) re = true;
            //SQLHelper.ExecuteSql("delete from COFCO_EXPERT_ARTICLE where ARTICLE_ID in (" + ids + ")", new SqlParameter[] { });
            return re;
        }

        public static bool Delkeywords(string ids)
        {
            bool re = false;
            string delsql = string.Format("delete from nestle_kewords where id in({0})", ids);
            int i = SQLHelper.ExecuteSql(delsql, new SqlParameter[] { });
            if (i > 0) re = true;
            //SQLHelper.ExecuteSql("delete from COFCO_EXPERT_ARTICLE where ARTICLE_ID in (" + ids + ")", new SqlParameter[] { });
            return re;
        }


        public static bool Updatedoctor(nestle_doctor info)
        {
            bool re = false;
            string updatesql = "update nestle_doctor set name=@name,job=@job,summary=@summary,blog=@blog,hospital=@hospital,experience=@experience"
                + ",indextop=@indextop,sorttop=@sorttop,isonline=@isonline,quicklink=@quicklink,columnid=@columnid,creattime=@creattime,onlinetime=@onlinetime,objectname=@objectname where id=" + info.Id;
            SqlParameter[] parms = new SqlParameter[] { 
                new SqlParameter("@name", SqlDbType.NVarChar, 50),
                new SqlParameter("@job", SqlDbType.NVarChar,50),
                new SqlParameter("@summary", SqlDbType.Text),
                new SqlParameter("@blog",SqlDbType.NVarChar,200),
                new SqlParameter("@hospital", SqlDbType.NVarChar,100),
                new SqlParameter("@experience", SqlDbType.Text),
                new SqlParameter("@indextop",SqlDbType.Int,50),
                new SqlParameter("@sorttop", SqlDbType.Int,50),
                new SqlParameter("@isonline", SqlDbType.Int,50),
                new SqlParameter("@quicklink", SqlDbType.Int,50),
                new SqlParameter("@columnid", SqlDbType.Int,50),
                new SqlParameter("@creattime", SqlDbType.DateTime),
                new SqlParameter("@onlinetime", SqlDbType.NVarChar,200),
                new SqlParameter("@objectname", SqlDbType.NVarChar,100)


            };
            parms[0].Value = info.Name;
            parms[1].Value = info.Job;
            parms[2].Value = info.Summary;
            parms[3].Value = info.Blog;
            parms[4].Value = info.Hospital;
            parms[5].Value = info.Experience;
            parms[6].Value = info.Indextop;
            parms[7].Value = info.Sorttop;
            parms[8].Value = info.Isonline;
            parms[9].Value = info.Quicklink;
            parms[10].Value = info.Columnid;
            parms[11].Value = info.Creattime;
            parms[12].Value = info.Onlinetime;
            parms[13].Value = info.Objectname;
            int i = SQLHelper.ExecuteSql(updatesql, parms);
            if (i > 0)
            {
                //SQLHelper.ExecuteSql("delete from COFCO_EXPERT_ARTICLE where ARTICLE_ID=" + article.Articleid, new SqlParameter[] { });
                //if (article.ExpertId > 0)
                //{
                //    string INSERT_EXPERT_SQL = "insert into COFCO_EXPERT_ARTICLE(EXPERT_ID,ARTICLE_ID) values(" + article.ExpertId + "," + article.Articleid + ")";
                //    SQLHelper.ExecuteSql(INSERT_EXPERT_SQL, new SqlParameter[] { });
                //}
                re = true;
            }
            return re;
        }

        public static int upImg(string imgFiled, string imgName, string id)
        {
            string sql = string.Format(" update nestle_doctor set {0}='{1}' where id={2}", imgFiled, imgName, id);
            return iuser.insert(sql);
        }


        public static DataTable getImg(string id)
        {
            string sql = string.Format("select * from nestle_doctor_img where doctorId={0}", id);
            return iuser.query(sql);
        }
        public static DataTable selImg(string felid, string id)
        {
            string sql = string.Format("select * from nestle_doctor_img where {0}={1}",felid ,id);
            return iuser.query(sql);
        }


        public static int delImg(string imgId)
        {
            string sql = string.Format("delete from nestle_doctor_img where imgId={0}", imgId);
            return iuser.insert(sql);
        }

        public static bool InsertImg(nestle_doctor_img info)
        {
            bool re = false;
            string insertsql = "insert into nestle_doctor_img(imgName,imgType,imgFileName,doctorId,imgOrder) "
                + "values(@imgName,@imgType,@imgFileName,@doctorId,@imgOrder);select @@IDENTITY";
            SqlParameter[] parms = new SqlParameter[] { 
                new SqlParameter("@imgName", SqlDbType.NVarChar, 50),
                new SqlParameter("@imgType", SqlDbType.NVarChar,50),
                new SqlParameter("@imgFileName", SqlDbType.NVarChar,200),
                new SqlParameter("@doctorId",SqlDbType.NVarChar,50),
                new SqlParameter("@imgOrder", SqlDbType.NVarChar,50)
            };
            parms[0].Value = info.ImgName;
            parms[1].Value = info.ImgType;
            parms[2].Value = info.ImgFileName;
            parms[3].Value = info.DoctorId;
            parms[4].Value = info.ImgOrder;
            int i = SQLHelper.ExecuteSql(insertsql, parms);
            if (i > 0)
            {
                re = true;

            }
            return re;
        }

        public static bool UpdataImg(nestle_doctor_img info,string imgId)
        {
            bool re = false;
            string updatesql = "update nestle_doctor_img set imgName=@imgName,imgType=@imgType,imgFileName=@imgFileName,imgOrder=@imgOrder,status=@status where imgId=" + imgId;            
            SqlParameter[] parms = new SqlParameter[] { 
                new SqlParameter("@imgName", SqlDbType.NVarChar, 50),
                new SqlParameter("@imgType", SqlDbType.NVarChar,50),
                new SqlParameter("@imgFileName", SqlDbType.NVarChar,200),
                new SqlParameter("@imgOrder",SqlDbType.NVarChar,50),
                new SqlParameter("@status", SqlDbType.NVarChar,50)
            };
            parms[0].Value = info.ImgName;
            parms[1].Value = info.ImgType;
            parms[2].Value = info.ImgFileName;
            parms[3].Value = info.ImgOrder;
            parms[4].Value = info.Status;
            int i = SQLHelper.ExecuteSql(updatesql, parms);
            if (i > 0)
            {
                //SQLHelper.ExecuteSql("delete from COFCO_EXPERT_ARTICLE where ARTICLE_ID=" + article.Articleid, new SqlParameter[] { });
                //if (article.ExpertId > 0)
                //{
                //    string INSERT_EXPERT_SQL = "insert into COFCO_EXPERT_ARTICLE(EXPERT_ID,ARTICLE_ID) values(" + article.ExpertId + "," + article.Articleid + ")";
                //    SQLHelper.ExecuteSql(INSERT_EXPERT_SQL, new SqlParameter[] { });
                //}
                re = true;
            }
            return re;
        }

        public static DataTable getFAQ()
        {
            string sql = string.Format("select * from nestle_doctor_FAQ order by creattime desc");
            return iuser.query(sql);
        }
        public static DataTable getFAQ(string id )
        {
            string sql = string.Format("select * from nestle_doctor_FAQ where id={0} order by creattime desc",id);
            return iuser.query(sql);
        }


        public static DataTable getFAQ(string filed,string vales)
        {
            string sql = string.Format("select * from nestle_doctor_FAQ where {0}={1} order by creattime desc", filed, vales);
            return iuser.query(sql);
        }
        public static DataTable getInfo(string vales1, string vales2)
        {
            string sql = string.Format("select * from nestle_doctor_FAQ where type={0} and status={1} order by creattime desc", vales1, vales2);
            return iuser.query(sql);
        }
        public static void insFAQ(nestle_doctor_FAQ info)
        {
            throw new NotImplementedException();
        }

        public static int upFaq(string values1, string values2, string values3, string values4, string values5, string values6, string values7, string values8, string values9, string values10, string id)
        {
            string sql = string.Format(" update nestle_doctor_FAQ set type={0},title='{1}',content='{2}',answer='{3}',status={4},doctorName='{5}',modtime='{6}',updatetime='{7}',ismore={8},isrecommend={9} where id={10}", values1, values2, values3, values4, values5, values6, values7, values8,values9,values10, id);
            return iuser.insert(sql);
        }

        public static int delFaq(string id)
        {
            string sql = string.Format("delete from nestle_doctor_FAQ where id={0}", id);
            return iuser.insert(sql);
        }
        public static int upMamaInfo(string mamaName, string babyName, string address, string desc, string videoName, string status,string fileName,string id)
        {
            string sql = string.Format(" update nestle_mama set mamaName='{0}',babyName='{1}',address='{2}',descc='{3}',videoName='{4}',status='{5}',fileName='{6}'where id={7}", mamaName, babyName, address, desc, videoName, status,fileName,id );
            return iuser.insert(sql);
        }

        public static DataTable getMama(string id)
        {
            string sql = string.Format("select * from nestle_mama where id={0} order by creattime desc", id);
            return iuser.query(sql);
        }
        public static DataTable getMama()
        {
            string sql = string.Format("select * from nestle_mama order by creattime desc");
            return iuser.query(sql);
        }

        public static int delMama(string id)
        {
            string sql = string.Format("delete from nestle_mama where id={0}", id);
            return iuser.insert(sql);
        }

        public static bool InsertMama(nestle_mama info)
        {
            bool re = false;
            string insertsql = "insert into nestle_mama(mamaName,babyName,address,descc,videoName,fileName,status,pic) "
                + "values(@mamaName,@babyName,@address,@descc,@videoName,@fileName,@status,@pic);select @@IDENTITY";
            SqlParameter[] parms = new SqlParameter[] { 
                new SqlParameter("@mamaName", SqlDbType.NVarChar, 50),
                new SqlParameter("@babyName", SqlDbType.NVarChar,50),
                new SqlParameter("@address", SqlDbType.NVarChar,200),
                new SqlParameter("@descc",SqlDbType.NVarChar,1000),
                new SqlParameter("@videoName", SqlDbType.NVarChar,50),
                new SqlParameter("@fileName", SqlDbType.NVarChar,50),
                new SqlParameter("@status", SqlDbType.NVarChar,50),
                new SqlParameter("@pic", SqlDbType.NVarChar,200)

            };
            parms[0].Value = info.MamaName;
            parms[1].Value = info.BabyName;
            parms[2].Value = info.Address;
            parms[3].Value = info.Descc;
            parms[4].Value = info.VideoName;
            parms[5].Value = info.Filename;
            parms[6].Value = info.Status;
            parms[7].Value = info.Pic;
            int i = SQLHelper.ExecuteSql(insertsql, parms);
            if (i > 0)
            {
                re = true;

            }
            return re;
        }

        public static int upMamaVideo(string field, string values, string id)
        {
            string sql = string.Format(" update nestle_mama set {0}='{1}' where id={2}", field, values, id);
            return iuser.insert(sql);
        }
        public static void upMama(string mamaName, string babyName, string address, string desc, string videoName, string file_name, string status, string p)
        {
            throw new NotImplementedException();
        }

        public static DataTable getdr()
        {
            string sql = string.Format("select name from nestle_doctor");
            return iuser.query(sql);
        }

        public static DataTable flash()
        {
            string sql = string.Format("select count from nestle_flash_count");
            return iuser.query(sql);
        }

        public static bool Updataflash(string values,string id)
        {
            bool re = false;
            string updatesql = string.Format("update nestle_flash_count set count={0} where id={1}", values, id);
            int i = SQLHelper.ExecuteSql(updatesql);
            if (i > 0)
            {
                //SQLHelper.ExecuteSql("delete from COFCO_EXPERT_ARTICLE where ARTICLE_ID=" + article.Articleid, new SqlParameter[] { });
                //if (article.ExpertId > 0)
                //{
                //    string INSERT_EXPERT_SQL = "insert into COFCO_EXPERT_ARTICLE(EXPERT_ID,ARTICLE_ID) values(" + article.ExpertId + "," + article.Articleid + ")";
                //    SQLHelper.ExecuteSql(INSERT_EXPERT_SQL, new SqlParameter[] { });
                //}
                re = true;
            }
            return re;
        }

        public static DataTable GetFAQlist(string max, string pageNum)
        {
            string sql = string.Format("select top {0} * from nestle_doctor_FAQ where (  id not in(select top {1} id from nestle_doctor_FAQ where status=1 order by creattime desc)) and status=1 order by creattime desc", max, pageNum);
            return iuser.query(sql);
        }

        public static DataTable GetFAQLB(string max, string pageNum, string lb, string lb1)
        {
            string sql = string.Format("select top {0} * from nestle_doctor_FAQ where (  id not in(select top {1} id from nestle_doctor_FAQ where status=1 and type={2} order by creattime desc)) and status=1 and type={3} order by creattime desc", max, pageNum, lb, lb1);
            return iuser.query(sql);
        }


        public static int countFAQ()
        {
            string sql = string.Format("select count(id) from nestle_doctor_FAQ where status=1");
            return iuser.getScalar(sql);
        }

        public static DataTable getIndexTopDocrot()
        {
            string sql = string.Format("select top 1 * from nestle_doctor where indextop=1 order by creattime desc");
            return iuser.query(sql);
        }

        public static DataTable getLiveDocrot()
        {
            string sql = string.Format("select top 1 * from nestle_doctor where isonline=1 order by creattime desc");
            return iuser.query(sql);
        }

        public static DataTable getMoreFAQ()
        {
            string sql = string.Format("select top 4 * from nestle_doctor_FAQ where ismore=1 and status=1 order by updatetime desc");
            return iuser.query(sql);
        }

        public static DataTable getRecommendFAQ()
        {
            string sql = string.Format("select top 5 * from nestle_doctor_FAQ where isrecommend=1 and status=1 order by updatetime desc");
            return iuser.query(sql);
        }

        public static DataTable getFaqBlog()
        {
            string sql = string.Format("select top 2 * from nestle_doctor where sorttop=1 order by creattime desc");
            return iuser.query(sql);
        }

        public static bool confimFAQ(string biaoti, string content, string faqtype, string username, string useremail)
        {
            bool re = false;
            string updatesql = string.Format("insert into nestle_doctor_FAQ(title,content,type,name,email) "
                + "values('{0}','{1}',{2},'{3}','{4}' );select @@IDENTITY", biaoti, content, faqtype, username, useremail);
            int i = SQLHelper.ExecuteSql(updatesql);
            if (i > 0)
            {
                //SQLHelper.ExecuteSql("delete from COFCO_EXPERT_ARTICLE where ARTICLE_ID=" + article.Articleid, new SqlParameter[] { });
                //if (article.ExpertId > 0)
                //{
                //    string INSERT_EXPERT_SQL = "insert into COFCO_EXPERT_ARTICLE(EXPERT_ID,ARTICLE_ID) values(" + article.ExpertId + "," + article.Articleid + ")";
                //    SQLHelper.ExecuteSql(INSERT_EXPERT_SQL, new SqlParameter[] { });
                //}
                re = true;
            }
            return re;
        }

        public static DataTable getindex(string columnid)
        {
            string sql = string.Format("select top 5 * from CMS_ARTICLE where INDEXTOP=1 and COLUMNID={0} order by pubtime desc",columnid);
            return iuser.query(sql);
        }

        public static DataTable getindexdoctor()
        {
            string sql = string.Format("select top 2 * from nestle_doctor where indextop=1 and isonline=1 order by creattime desc");
            return iuser.query(sql);
        }

        public static DataTable GetIndexRight()
        {
            string sql = string.Format("select top 1 * from CMS_ARTICLE where INDEXTOP=1 and isbanner=1 and COLUMNID=180 order by modtime desc");
            return iuser.query(sql);
        }

        public static DataTable GetVideoOne()
        {
            string sql = string.Format("select top 1 * from nestle_mama where status=1 order by creattime desc");
            return iuser.query(sql);
        }

        public static DataTable GetVideo(string id)
        {
            string sql = string.Format("select * from nestle_mama where id={0} and status=1  order by creattime desc",id);
            return iuser.query(sql);
        }



        public static DataTable GetVideo()
        {
            string sql = string.Format("select * from nestle_mama where status=1  order by creattime desc");
            return iuser.query(sql);
        }

        public static DataTable getallart()
        {
            string sql = string.Format("select top 5000 * from CMS_ARTICLE order by ADD_TIME");
            return iuser.query(sql);
        }

        public static DataTable getKeywords()
        {
            string sql = string.Format("select top 12 * from nestle_kewords where status=1 and recommend=1 order by num desc");
            return iuser.query(sql);
        }
        public static DataTable getKeywords(string name)
        {
            string sql = string.Format("select * from nestle_kewords where keword='{0}'",name);
            return iuser.query(sql);
        }


        public static int selkey(string name)
        {
            string sql = string.Format("select count(keword) from nestle_kewords where keword='{0}'", name);
            return iuser.getScalar(sql);
        }

        public static int updatekey(string num,string name)
        {
            string sql = string.Format("update nestle_kewords set num={0} where keword='{1}'", num, name);
            return iuser.insert(sql);
        }

        public static int inskey(string name)
        {
            string sql = string.Format("insert into nestle_kewords(keword) values('{0}')",name);
            return SQLHelper.ExecuteSql(sql);
        }

        public static DataTable getpid(string columid)
        {
            string sql = string.Format("select * from CMS_COLUMN where CLASSID={0}", columid);
            return iuser.query(sql);
        }

        public static DataTable getpename(string pid)
        {
            string sql = string.Format("select * from CMS_COLUMN where CLASSID={0}", pid);
            return iuser.query(sql);
        }

        public static DataTable getallkeywords()
        {
            string sql = string.Format("select * from nestle_kewords order by num desc");
            return iuser.query(sql);
        }
        public static DataTable getallkeywords(string id)
        {
            string sql = string.Format("select * from nestle_kewords where id={0}",id);
            return iuser.query(sql);
        }

        public static bool Updatekeyword(nestle_kewords info)
        {
            bool re = false;
            string updatesql = "update nestle_kewords set keword=@keword,num=@num,recommend=@recommend,status=@status where id=" + info.Id;
            SqlParameter[] parms = new SqlParameter[] { 
                new SqlParameter("@keword", SqlDbType.NVarChar, 50),
                new SqlParameter("@num", SqlDbType.Int),
                new SqlParameter("@recommend", SqlDbType.NVarChar, 50),
                new SqlParameter("@status",SqlDbType.NVarChar, 50),


            };
            parms[0].Value = info.Keword;
            parms[1].Value = info.Num;
            parms[2].Value = info.Recommend;
            parms[3].Value = info.Status;
            int i = SQLHelper.ExecuteSql(updatesql, parms);
            if (i > 0)
            {
                re = true;
            }
            return re;
        }
    }
}
       
                
    
